import {defineConfig} from "vite"
import vue from "@vitejs/plugin-vue"
import unocss from "unocss/vite"
import autoImport from "unplugin-auto-import/vite"
import {resolve} from "path"
import {presetIcons, presetUno} from "unocss"
import carbon from "@iconify-json/carbon"

export default defineConfig({
    plugins: [
        vue(),
        autoImport({
            imports: ["vue", "vue-router"],
            dts: "src/auto-import.d.ts",
        }),
        unocss({
            shortcuts: {
                "full~": "w-full h-full",
                "image~": "bg-center bg-no-repeat bg-cover",
                "center~": "flex justify-center items-center",
                "between~": "flex justify-between items-center",
                "demand-create-table-td~": "text-left p-10px",
                "demand-create-table-th~": "text-left bg-blue-600 p-10px text-light-50"
            },
            presets: [
                presetUno(),
                presetIcons({
                    collections: {
                        carbon: carbon.icons as any
                    }
                })
            ]
        })
    ],
    resolve: {
        alias: {
            "@": resolve(__dirname, "./src"),
            "@pages": resolve(__dirname, "./src/pages"),
            "@components": resolve(__dirname, "./src/components")
        }
    },
    server: {
        proxy: {
            "/api": {
                target: "http://127.0.0.1:8081",
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/api/, "")
            }
        }
    }
})